package ecom.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * 
 * @author François Haurit
 * @version 1.0
 */
@Embeddable
public class LignePK implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "id_commande", nullable = false)
    private Long idCommande;

    @Column(name = "reference_product", nullable = false)
    private Long referenceProduct;

    public LignePK() {
    }

    /**
     * Constructeur complet.
     */
    public LignePK(Long idCommande, Long referenceProduct) {
	super();
	this.idCommande = idCommande;
	this.referenceProduct = referenceProduct;
    }

    public Long getIdCommande() {
	return this.idCommande;
    }

    public void setIdCommande(Long idCommande) {
	this.idCommande = idCommande;
    }

    public Long getReferenceProduct() {
	return this.referenceProduct;
    }

    public void setReferenceProduct(Long referenceProduct) {
	this.referenceProduct = referenceProduct;
    }

    @Override
    public int hashCode() {
	int prime = 31;
	int result = 1;
	result = prime * result
		+ ((idCommande == null) ? 0 : idCommande.hashCode());
	result = prime
		* result
		+ ((referenceProduct == null) ? 0 : referenceProduct.hashCode());
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if (obj == null) {
	    return false;
	}
	if (!(obj instanceof LignePK)) {
	    return false;
	}
	LignePK other = (LignePK) obj;
	if (idCommande == null) {
	    if (other.idCommande != null) {
		return false;
	    }
	} else if (!idCommande.equals(other.idCommande)) {
	    return false;
	}
	if (referenceProduct == null) {
	    if (other.referenceProduct != null) {
		return false;
	    }
	} else if (!referenceProduct.equals(other.referenceProduct)) {
	    return false;
	}
	return true;
    }

    @Override
    public String toString() {
	return "LignePK [idCommande=" + idCommande + ", referenceProduct="
		+ referenceProduct + "]";
    }
}